package src.controller;

import java.awt.BorderLayout;



import src.service.ClientService;
import src.view.AddMailBox;
import src.view.AddPostOffice;
import src.view.AddUser;
import src.view.MainMenu;
import src.view.ManageMailBoxes;
import src.view.ManagePostOffices;
import src.view.ManageTrustRelationships;
import src.view.ManageUsers;

public class MainMenuController {
	
	private ClientService system;
	private MainMenu view;
	
	
	public MainMenuController(ClientService system){
		this.view=MainMenu.getInstance(this);
		this.system=system;
		
	}
	
	private void removeJPanel() {
		this.view.getPanel().remove(this.view.getJPanelCenter());
		this.view.setJPanelCenter(null);
		this.view.getPanel().repaint();
	}
	
	public void performShowAddUser(){
		removeJPanel();
		this.view.setJPanelCenter(AddUser.getInstance(new AddUserController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowManageUsers(){
		removeJPanel();
		this.view.setJPanelCenter(ManageUsers.getInstance(new ManageUsersController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowAddPostOffice(){
		removeJPanel();
		this.view.setJPanelCenter(AddPostOffice.getInstance(new AddPostOfficeController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowManagePostOffices(){
		removeJPanel();
		this.view.setJPanelCenter(ManagePostOffices.getInstance(new ManagePostOfficesController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowManageTrustRelationships(){
		removeJPanel();
		this.view.setJPanelCenter(ManageTrustRelationships.getInstance(new ManageTrustRelationshipsController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowAddMailBox(){
		removeJPanel();
		this.view.setJPanelCenter(AddMailBox.getInstance(new AddMailBoxController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	
	public void performShowManageMailBox(){
		removeJPanel();
		this.view.setJPanelCenter(ManageMailBoxes.getInstance(new ManageMailBoxesController(this.system)));
		this.view.getPanel().add(this.view.getJPanelCenter(),BorderLayout.CENTER);
		this.view.getPanel().validate();
		
	}
	

}
